<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var Data = new Date()
        let year = Data.getFullYear()
        let month = Data.getMonth() + 1
        let day = Data.getDate()
        let hour = Data.getHours()
        let minute = Data.getMinutes()
        let seconds = Data.getSeconds()
        //变成字符串的数字
        let strmon = month.toString()
        // console.log(strmon);
        let strday = day.toString()
        let strhour = hour.toString()
        let strminute = minute.toString()
        let strseconds = seconds.toString()

        //补零之后的字符串
        let add0mon = strmon.padStart(2, '0')
        let add0day = strday.padStart(2, '0')
        let add0hour = strhour.padStart(2, '0')
        let add0minute = strminute.padStart(2, '0')
        let add0seconds = strseconds.padStart(2, '0')
        let str = `${year}-${add0mon}-${day} ${hour}:${minute}:${seconds}`
        console.log(str);


    </script>
</body>

</html>